<template>
  <el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" :close-on-click-modal="false" lock-scroll append-to-body>
    <el-row :gutter="15" >
      <!-- 设施设备 -->
      <el-form v-if="type == 0" :model="formDate" :rules="rules" label-width="110px" ref="elForm">
        <el-col :span="20">
          <el-form-item label="检查项目" >
            <el-input v-model="formDate.jcxm" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="检查标准" >
            <el-input v-model="formDate.jcbz" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="不符合标准情况" >
            <el-input v-model="formDate.bfhbzqk" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="主要后果" >
            <el-input v-model="formDate.zyhg" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
      <!-- 作业活动 -->
      <el-form v-if="type == 1" :model="formDate" :rules="rules" label-width="180px" ref="elForm">
        <el-col :span="22">
          <el-form-item label="作业步骤" >
            <el-input v-model="formDate.zybz" type="textarea" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="22">
          <el-form-item label="危险源或潜在事件" >
            <el-input v-model="formDate.wxyhqzsj" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="22">
          <el-form-item label="可能发生的事故类型及后果" >
            <el-input v-model="formDate.knfsdsjlxjhg" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
      <!-- 工艺节点 -->
      <el-form v-if="type == 2" :model="formDate" :rules="rules" label-width="110px" ref="elForm">
        <el-col :span="20">
          <el-form-item label="节点" >
            <el-input v-model="formDate.jd" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="参数" >
            <el-input v-model="formDate.cs" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="参数描述" >
            <el-input v-model="formDate.csms" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="引导词" >
            <el-input v-model="formDate.ydc" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="可能原因" >
            <el-input v-model="formDate.knyy" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="偏差" >
            <el-input v-model="formDate.pc" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="主要后果" >
            <el-input v-model="formDate.zyhg" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return{
      index:'',
      title:"添加",
      formDate:{}, // form
      dialogFormVisible:false,
      type:'',
      rules:{
        jcxm: [
          { required: true, message: '请填写检查项目', trigger: 'blur' }
        ]
      },
    }
  },
  methods:{
    init(type,row,distinguish,index) {
      this.index = index
      this.formDate = {}
      this.type = type
      this.distinguish = distinguish || false
      if(distinguish) {
        this.title = "编辑"
        this.formDate = row
      } else {
        this.title = "添加"
      }
      this.dialogFormVisible = true
    },
    submitForm() {
      this.dialogFormVisible = false
        this.$emit('refreshDataList',this.formDate,this.distinguish)
        this.formDate = {}
    }
  }
}
</script>

<style>

</style>